<?php
/* 
 *管理
 */
class Product_mapAction extends CommonAction {
    public function _filter(&$map) {
        $key = trim($_REQUEST['keywords']);
        if(!empty($key)) {
            $map['Common_product.name'] = array('like',"%".$key."%");//url
            $map['out_number'] = array('like',"%".$key."%");//url
            $map['my_number'] = array('like',"%".$key."%");//url
            $map['_logic'] = "or";
        }
    }

    public function index()
    {
        parent::index('Product_mapView');
    }

    public function _before_insert(){
        $_POST['my_number'] = $_POST['common_id'];
        $con = array(
            'my_number' =>  $_POST['my_number'],
            'order_source_id' => $_POST['order_source_id'],
            );
        $rs = M('Product_map')->where($con)->find();
        if(is_array($rs))
            $this->error('已存在对应映射，请更换产品！');
    
    }

    public function _before_update(){
        $_POST['my_number'] = $_POST['common_id'];
        $con = array(
            'my_number' =>  $_POST['my_number'],
            'id' => array('neq',$_POST['id']),
            'order_source_id' => $_POST['order_source_id'],
            );
        $rs = M('Product_map')->where($con)->find();
        if(is_array($rs))
            $this->error('已存在对应映射，请更换产品！');
    
    }


}
?>
